<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>模板字符串</title>
</head>

<body>
    <p>模板字符串是增强版的字符串，用反引号（`）标识。它可以当作普通字符串使用，也可以用来定义多行字符串，或者在字符串中嵌入变量。</p>
    <p>//普通字符串</p>
    <p>`Hello World`;</p>
    <p>//多行字符串</p>
    <p>`Hello</p>
    <p>World!`</p>
    <p>//字符串中嵌入变量</p>
    <p>var name = 'Bob',time = "today";</p>
    <p>`Hello ${name},how are you ${time}?`;</p>
    <p style="color:#ff0000;">在模板字符串中嵌入变量，需要将变量名写在${}中。</p>
    <script>
        //传统的写法
        $('#result').append(
            'There are <b>' + basket.count + '</b> ' +
            'items in your basket, ' +
            '<em>' + basket.onSale +
            '</em> are on sale!'
        );
        $('#result').append(`
         There are <b>${basket.count}</b> items
         in your basket, <em>${basket.onSale}</em>
          are on sale!
          `);
          $("#result").append(`
          There are <b>${basket.count } </b> 
            items in your basket, <em> ${basket.onSale}  </em> are on sale!'
          `)
    </script>
</body>

</html>